package com.qf.controller;


import com.qf.service.SearchService;
import com.qf.util.JsonUtil;
import com.qf.util.SearchPojo;
import com.qf.util.SmsStatusDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author 何星宇
 * @version V1.0
 * @Date 2021/11/25 18:58
 */

@RestController
public class SearchController {
    @Autowired
    private SearchService searchService;

    /**
     * 根据条件查询日志集合数据返回
     * @param paras
     */
    @RequestMapping(value = "/search/search", method = RequestMethod.POST)
    List<Map> searchLog(@RequestParam("params") String paras) throws IOException {
        SearchPojo searchPojo = (SearchPojo) JsonUtil.getObj(paras, SearchPojo.class);
        return searchService.searchLog(searchPojo);
    }

    /**
     * 根据条件查询日志总条数
     * @param paras
     */
    @RequestMapping(value = "/search/searchcount", method = RequestMethod.POST)
    Long searchLogCount(@RequestParam("params") String paras) throws IOException {
        SearchPojo searchPojo = (SearchPojo) JsonUtil.getObj(paras, SearchPojo.class);
        return searchService.searchLogCount(searchPojo);
    }

    /**
     * 统计报表查询
     * @param paras
     */
    @RequestMapping(value = "/search/statStatus", method = RequestMethod.POST)
    public Map<String, Long> statSendStatus(@RequestParam("params") String paras) throws IOException {
        SmsStatusDTO smsStatusDTO = (SmsStatusDTO) JsonUtil.getObj(paras, SmsStatusDTO.class);
        return searchService.statSendStatus(smsStatusDTO);
    }
}
